package coms;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;

public class ConnectingServer extends Connecting {
	
	ServerSocket myServerSocket;
	
	public ConnectingServer(int port) {
		/**
		 * The constructor takes a port and listens for connections on it (blocking)
		 * until a connection is made.
		 */
		try{
			myServerSocket = new ServerSocket(port);
			mySocket = myServerSocket.accept();
			this.SetUpPrintWriterAndBufferedReader();
		}
		catch (IOException e) {
			System.out.println("failed to make serversocket or accept");
		}	
	}
	
	public InetAddress getInetAddress() {
		/**
		 * Returns the InetAddress of the server.
		 */
		return myServerSocket.getInetAddress();
	}
	
		
		
}